package com.zy.core.web.form;

import java.util.LinkedHashMap;

import com.zy.pro.system.model.Employee;
//import com.zy.pro.system.model.Role;

/**
 * 查询基类
 * 
 * @author
 * 
 */
public class BaseSearchForm {
	/**
	 * 页号
	 */
	private int page = 1;

	private int firstResult;

	private int maxResult;

	private LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();

	//ADD BY JIANGYINGXU 员工信息
	private Employee empSession;
	
	//ADD BY JIANGYINGXU 员工对应角色信息
//	private Role roleSession;
	
	private int  vail;//2014/8/27判断条件
	private int  loginUserId;//2014/8/27登录人id
	
	private String sortName;
	private String sortOrder;
	
	public int getLoginUserId() {
		return loginUserId;
	}

	public void setLoginUserId(int loginUserId) {
		this.loginUserId = loginUserId;
	}

	
	public int getVail() {
		return vail;
	}

	public void setVail(int vail) {
		this.vail = vail;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getFirstResult() {
		return firstResult;
	}

	public void setFirstResult(int firstResult) {
		this.firstResult = firstResult;
	}

	public int getMaxResult() {
		return maxResult;
	}

	public void setMaxResult(int maxResult) {
		this.maxResult = maxResult;
	}

	public LinkedHashMap<String, String> getOrderby() {
		return orderby;
	}

	public String getOrderCondition() {
		StringBuffer orderCondition = new StringBuffer("");
		// step1:判断orderby是否为空
		if (orderby.isEmpty()) {
			return orderCondition.toString();
		} else {
			// step2:遍历orderby装成排序
			orderCondition.append("order by ");
			for (String key : orderby.keySet()) {
				orderCondition.append(key).append(" ").append(orderby.get(key)).append(",");
			}
			orderCondition.deleteCharAt(orderCondition.length() - 1);
			return orderCondition.toString();
		}
	}

	public String getQueryCondition() {
		StringBuffer condition = new StringBuffer(" ");
		condition.append("limit ").append(firstResult).append(",").append(maxResult);
		return condition.toString();
	}

	public Employee getEmpSession() {
		return empSession;
	}

	public void setEmpSession(Employee empSession) {
		this.empSession = empSession;
	}

	/*public Role getRoleSession() {
		return roleSession;
	}

	public void setRoleSession(Role roleSession) {
		this.roleSession = roleSession;
	}*/

	public String getSortName() {
		return sortName;
	}

	public void setSortName(String sortName) {
		this.sortName = sortName;
		if(!"".equals(sortName) && null != sortName){
			this.orderby.put(sortName, this.sortOrder);
		}
	}

	public String getSortOrder() {
		return sortOrder;
	}

	public void setSortOrder(String sortOrder) {
		this.sortOrder = sortOrder;
		if(!"".equals(sortOrder) && null != sortOrder){
			this.orderby.put(this.sortName, sortOrder);
		}
	}
	
	
}
